package com.abe.libquick.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.abe.libquick.base.mvp.BaseLogPresenter;
import com.abe.libquick.base.mvp.BaseView;


public abstract class MvpBaseFragment<V extends BaseView, P extends BaseLogPresenter<V>> extends BaseFragment {

    protected P mPresenter;

    protected abstract P createPresenter();

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //创建Presenter
        mPresenter = createPresenter();
        //填充View
        if (mPresenter != null) {
            mPresenter.attachView((V) this);
        }
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (mPresenter != null) {
            mPresenter.detachView();
        }
    }
}